package com.huishu.user.controller;


import com.huishu.commons.pojo.Result;
import com.huishu.user.pojo.dto.PageListDTO;
import com.huishu.user.pojo.dto.RoleDTO;
import com.huishu.user.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @author generator@ljj
* @since 2023-04-21
*/
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @PostMapping("/add")
    public Result add(@RequestBody RoleDTO roleDTO) {
        return roleService.add(roleDTO);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        return roleService.deleteRole(id);
    }

    @PostMapping("/update")
    public Result update(@RequestBody RoleDTO role) {
        return roleService.modify(role);
    }

    @PostMapping("/pageList")
    public Result pageList(@RequestBody PageListDTO pageListDTO) {
        return roleService.pageList(pageListDTO);
    }

    @GetMapping("/info/{id}")
    public Result getRoleInfo(@PathVariable Long id) {
        return roleService.getRoleInfo(id);
    }

    @PostMapping("/findAll")
    public Result findAll() {
        return Result.success(roleService.list());
    }
}
